function eye_analysis_to_file(userID)

tmp_data_dir = '\\KELLER-RIG1-ANA\RawData\';
[~,host] = dos('hostname');
if ~isempty(regexp(host,'f410l-c2cdd3', 'once'))
    adata_dir='G:\AData\';
    stacks_dir='G:\ExpLog\Stacks.xlsx';
else
    adata_dir='\\argon.fmi.ch\keller.g\AData\';
    stacks_dir='\\argon.fmi.ch\keller.g\ExpLog\Stacks.xlsx';
end

eye_data_dir='\\argon.fmi.ch\keller.g\AData\zmarpawe\eye_analysis\';

[xls_num,xls_txt]=xlsread(stacks_dir);
expIDs=[];
cnt=1;
for ynd=1:size(xls_num,1)
    if ~isempty(strfind(xls_txt{ynd+1,10},userID))
        expIDs(cnt)=xls_num(ynd,2);
        cnt=cnt+1;
    end
end
expIDs=unique(expIDs);
% expIDs=[3858        4033        4192        4327        4356        4402        4532];

for ynd=1:length(expIDs)
    cur_fname=[eye_data_dir 'PZeye_' num2str(expIDs(ynd)) '.mat'];
    if ~exist(cur_fname,'file')
        display(['Loading exp ' num2str(expIDs(ynd))])
        [adata_file,mouse_id,userID]=find_adata_file(expIDs(ynd),adata_dir);
        orig=load([adata_dir userID '\' mouse_id '\' adata_file],'nbr_frames','aux_files');
        
        aux_data=[];
        try
            for ind=1:length(orig.aux_files)
                if exist([tmp_data_dir userID '\' mouse_id '\' orig.aux_files{ind}],'file');
                    disp(['loading file ' orig.aux_files{ind} ' from local tmpdata directory']);
                    curr_load_path=[tmp_data_dir userID '\' mouse_id '\' orig.aux_files{ind}];
                else
                    disp(['loading file ' orig.aux_files{ind} ' from the network RawData directory']);
                    curr_load_path=[rdata_dir userID '\' mouse_id '\' orig.aux_files{ind}];
                end
                
                tmp_data=load_lvd(curr_load_path);
                tmp_frames=get_frame_times(tmp_data(2,:));
                
                if orig.nbr_frames(ind)~=length(tmp_frames)
                    if max(diff(tmp_frames))/median(diff(tmp_frames))<1.5 & length(tmp_frames)>orig.nbr_frames(ind)
                        disp('NC WARNING! Probably scanning too fast for FPGA to stop in the same frame')
                        disp(['--- ' num2str(length(tmp_frames)-orig.nbr_frames(ind)) ' frames too many ---'])
                        tmp_data(2,tmp_frames(orig.nbr_frames(ind)+1):end)=0;
                    else
                        disp('CRITICAL WARNING! - aux data longer than it should be.')
                        %return
                        %tmp_data=tmp_data(:,1:tmp_frames(nbr_frames(ind)+1));
                        [~,last_bad_frame]=max(diff(tmp_frames));
                        tmp_data=tmp_data(:,ceil(mean([tmp_frames(last_bad_frame) tmp_frames(last_bad_frame+1)])):end);
                    end
                end
                aux_data(:,end+1:end+length(tmp_data))=tmp_data;
            end
            
            frame_times=get_frame_times(aux_data(2,:));
            
            %         vars_to_assigin_base={vars_to_assigin_base{:}, 'aux_data', 'frame_times'};
        catch
            disp('Did not load aux data')
        end
        
        
        idata=zeros(0,0,0,'uint8');
        imeta_data=[];
        no_eye_data=0;
        for ind=1:length(orig.aux_files)
            if exist([tmp_data_dir userID '\' mouse_id  '\' orig.aux_files{ind}(1:end-4) '.eye'],'file');
                disp(['loading file ' orig.aux_files{ind}(1:end-4) '.eye' ' from local tmpdata directory']);
                curr_load_path=[tmp_data_dir userID '\' mouse_id '\' orig.aux_files{ind}(1:end-4) '.eye'];
            elseif exist([rdata_dir userID '\' mouse_id '\' orig.aux_files{ind}(1:end-4) '.eye'],'file');
                disp(['loading file ' orig.aux_files{ind}(1:end-4) '.eye' ' from the network RawData directory']);
                curr_load_path=[rdata_dir userID '\' mouse_id '\' orig.aux_files{ind}(1:end-4) '.eye'];
            else
                disp('No eye data found!')
                no_eye_data=1;
                break
            end
            [tmp_idata, tmp_imeta_data] = load_eye_monitor_data(curr_load_path,1);
            orig.nbr_iframes(ind)=length(tmp_imeta_data);
            if ind==1||sum(size(idata(:,:,1))==size(tmp_idata(:,:,1)))==2
                idata(:,:,end+1:end+size(tmp_idata,3))=tmp_idata;
            else
                disp('Idata sizes don''t match - will improvise');
                idata(1:size(tmp_idata,1),1:size(tmp_idata,2),end+1:end+size(tmp_idata,3))=tmp_idata;
            end
            
            imeta_data(:,end+1:end+length(tmp_imeta_data))=tmp_imeta_data;
        end
        if ~no_eye_data
            [iframe_times]=get_iframe_times(imeta_data,aux_data(1,:),orig.nbr_iframes);
        end
        
        try
            [~, pupil_diam, pupil_pos, blink] = find_saccades(idata);
            save_eye_analysis(cur_fname,pupil_diam,pupil_pos,blink,iframe_times);
        catch
            display(['CR error: exp ' num2str(expIDs(ynd)) ' eye analysis not saved'])
        end
    else
        display(['exp ' num2str(expIDs(ynd)) ' - eye analysis already saved'])
    end
end